<template>
  <div>
    <div>今天:{{ today.format('YYYY-MM-DD') }}</div>
    <div>7天前日期: {{ startDateOfSevenDayBefore.format('YYYY-MM-DD') }}</div>
    <div>前7天: {{ dateArr }}</div>
  </div>
</template>

<script setup>
import dayjs from 'dayjs'
import 'dayjs/locale/zh-cn'
dayjs.locale('zh-cn')

const today = dayjs()
// 获取本周开始日期
let startDateOfSevenDayBefore = today.subtract(6, 'day')
const dateArr = new Array(7).fill(true).map((_, idx) => startDateOfSevenDayBefore.add(idx, 'day').format('YYYY-MM-DD'))
</script>
